#ifndef MIKROFLASH_H
#define MIKROFLASH_H

#include "Mikro.h"

/* M25P80 peripheral 1MB flash memory */

// Memory Organization
#define M25P80_TOTAL_SECTORS    (16)
#define M25P80_PAGES_PER_SECTOR (256)
#define M25P80_BYTES_PER_PAGE   (256)

// Initialize the status register; call this function first.
void M25P80_Init(void);

// Erase single sector
void M25P80_sector_erase(uint8 sectorNumber);

// Erase entire memory
void M25P80_bulk_erase();

// Program a page (only one page can be programmed at a time)
void M25P80_page_program(uint32 pageAddr, uint16 num_bytes, uint8 *write_data);

// Read bytes starting at an arbitrary address
void M25P80_read(uint32 addr, uint16 num_bytes, uint8 *read_data);


#endif /* MIKROFLASH_H */
